from functools import wraps
from flask import g,redirect,url_for
from flask import abort, request, jsonify, session
from flask_login import login_required, current_user
from applications.common.admin_log import admin_log

def user_login_required(log: bool = False):
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            # 判断是否有登录
            if hasattr(g, 'client_user'):
                return func(*args, **kwargs)
            else:
                return redirect(url_for("user.user_login"))
        return wrapper

    return decorator